package data.utils;

import java.util.SortedSet;

import data.ClusteredNode;
import data.Gene;

public class SingleLink extends ClusterDistanceCalculator {

	@Override
	public double distance(ClusteredNode c1, ClusteredNode c2) {
		GeneDistanceCalculator calculator = getGeneDistanceCalculator();
		double min=Double.MAX_VALUE;
		SortedSet<Gene> genes1 = c1.getGenes();
		SortedSet<Gene> genes2 = c2.getGenes();
		for (Gene g1:genes1) { 
			for (Gene g2:genes2) { 
				min=Math.min(calculator.distance(g1,g2), min);
			}
		}
		return min;
	}

}
